import 'package:flutter/material.dart';
import 'package:flutter_yishop/provider/Cart.dart';
import 'package:flutter_yishop/provider/CheckOut.dart';
import 'package:provider/provider.dart';
import 'config/StorageManager.dart';
import 'constants/Constants.dart';
import 'routes/Routes.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  //初始化
  await StorageManager.init();
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MyApp();
  }
}

class _MyApp extends State<MyApp> {
  @override
  Future<void> initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MultiProvider(
        providers:[
          ChangeNotifierProvider(create: (_) => Cart()),
          ChangeNotifierProvider(create: (_) => CheckOut()),
        ],
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          initialRoute: Constants.SPLASH,
          //初始化加载路由
          onGenerateRoute: onGenerateRoute,
          theme: ThemeData(primaryColor: Colors.white),
          // navigatorKey: StorageManager.navKey,
        ),
    );
  }
}
